package com.ruoyi.web.controller.supermarket;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supermarket.domain.Income;
import com.ruoyi.supermarket.service.IIncomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 薪资管理Controller
 * 
 * @author wqr
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/income/income")
public class IncomeController extends BaseController
{
    @Autowired
    private IIncomeService incomeService;

    /**
     * 查询薪资管理列表
     */
    @PreAuthorize("@ss.hasPermi('income:income:list')")
    @GetMapping("/list")
    public TableDataInfo list(Income income)
    {
        startPage();
        List<Income> list = incomeService.selectIncomeList(income);
        return getDataTable(list);
    }

    /**
     * 导出薪资管理列表
     */
    @PreAuthorize("@ss.hasPermi('income:income:export')")
    @Log(title = "薪资管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Income income)
    {
        List<Income> list = incomeService.selectIncomeList(income);
        ExcelUtil<Income> util = new ExcelUtil<Income>(Income.class);
        util.exportExcel(response, list, "薪资管理数据");
    }

    /**
     * 获取薪资管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('income:income:query')")
    @GetMapping(value = "/{iid}")
    public AjaxResult getInfo(@PathVariable("iid") Long iid)
    {
        return success(incomeService.selectIncomeByIid(iid));
    }

    /**
     * 新增薪资管理
     */
    @PreAuthorize("@ss.hasPermi('income:income:add')")
    @Log(title = "薪资管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Income income)
    {
        return toAjax(incomeService.insertIncome(income));
    }

    /**
     * 修改薪资管理
     */
    @PreAuthorize("@ss.hasPermi('income:income:edit')")
    @Log(title = "薪资管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Income income)
    {
        return toAjax(incomeService.updateIncome(income));
    }

    /**
     * 删除薪资管理
     */
    @PreAuthorize("@ss.hasPermi('income:income:remove')")
    @Log(title = "薪资管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iids}")
    public AjaxResult remove(@PathVariable Long[] iids)
    {
        return toAjax(incomeService.deleteIncomeByIids(iids));
    }
}
